package com.company.class8;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Classname RegexPractice
 * @Description 类型说明
 * @Date 2022/5/2 16:34
 * @Created by zbw
 */

public class RegexPractice {
    public static void main(String[] args) {
        //获取到标题和url的对应 简介：/regexp/regexp-intro.html  语法/regexp/regexp-syntax.html
        String s = "<a target=\"_top\" title=\"正则表达式 – 简介\" href=\"/regexp/regexp-intro.html\" style=\"background-color: rgb(150, 185, 125); font-weight: bold; color: rgb(255, 255, 255);\"><i class=\"fa fa-tag\" aria-hidden=\"true\"></i>\n" +
                "\t\t\t正则表达式 - 简介\t\t\t</a>"+
                "<a target=\"_top\" title=\"正则表达式 – 语法\" href=\"/regexp/regexp-syntax.html\">\n" +
                "\t\t\t正则表达式 - 语法\t\t\t</a>";
//        System.out.println(s);
        String regex = "– (.{2}?)\" href=\"(.+?)\"";
//        String regex = "– (.{2}?)\" href=\"(.+?)\"";
//        System.out.println("\"");

        Pattern p = Pattern.compile(regex);
        Matcher matcher = p.matcher(s);
        while (matcher.find()){
            System.out.println(matcher.group(0));
            System.out.println(matcher.group(1) + "：" + matcher.group(2));
        }

    }
}
